package com.xing.Utils;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2023/4/28 8:19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(name = "Result响应")
public class Result implements Serializable {
    private Integer code;
    private Object data;
    private String msg;

    static Result result = new Result();
    public Result ok(Object data){
        result.setCode(200);
        result.setData(data);
        result.setMsg("SUCCESS");
        return result;
    }

    public Result ok(){
        result.setCode(200);
        result.setMsg("SUCCESS");
        return result;
    }

    public Result err(Integer code, String msg){
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public Result err(Integer code){
        result.setCode(code);
        result.setMsg("ERROR");
        return result;
    }
}

